<template>
  <div>
    <form  @submit.prevent="fn">
      <label>姓名：</label>
      <input type="text" v-model="name"><br><br>

      <label>年龄：</label>
      <input type="number" v-model="age"><br><br>


      <label>身高：</label>
      <input type="number" v-model="height">(米)<br><br>

      <label>体重：</label>
      <input type="number" v-model="weight">(公斤)<br><br>

      <label>病史：</label>
      <input type="text" v-model="history"><br><br>

      <button>诊断</button>
    </form>

    <p v-show="flag">患者 {{name}} 的诊断结果：
      <span v-if="BMI < 18.5">体重过轻</span>
      <span v-else-if="BMI>= 18.5 && BMI < 24.9">健康</span>
      <span v-else>过重</span>
    </p>
  </div>
</template>

<script>
export default {
  data () {
    return {
      flag: false,
name:'',
age:'',
height:'',
weight:'',
history:'',
BMI: ''
    }
  },
  methods: {
fn(e){
    e.preventDefault()
this.BMI = this.weight /(this.height*this.height)
this.flag = !this.flag
console.log(this.BMI);
}
  }
}
</script>
